// 收集模型信息
// 格式 (转大写) Ext
// 尺寸 (体积) FileSize
// 贴图数量 Texture
// 动画 Animation
// 三角面数量 Triangles
// 顶点数 Vertices
// UV信息 HasUv
const collectModalInfo = function (objectTree, fileSize = "") {
  const { Objects } = objectTree;
  const info = {
    Animation: 0,
    Ext: this.modalType,
    FileSize: fileSize === 'NaN' ? '' : fileSize,
    HasUv: false,
    Texture: 0,
    Triangles: 0,
    Vertices: 0,
  };
  const { AnimationStack, Texture, Geometry } = Objects;
  if (AnimationStack) {
    info.Animation = Object.keys(AnimationStack).length;
  }
  if (Texture) {
    info.Texture = Object.keys(Texture).length;
  }
  if (Geometry && Object.keys(Geometry).length > 0) {
    for (const geometryKey in Geometry) {
      const item = Geometry[geometryKey];
      const { LayerElementUV, PolygonVertexIndex, Vertices } = item;
      info.Triangles += Math.ceil(PolygonVertexIndex.a.length / 3);
      info.Vertices += Math.ceil(Vertices.a.length / 3);
      info.HasUv = !!LayerElementUV;
    }
  }

  this.modalDetailInfo = info;
  this.getModalInfo(info, this.infoPanel);
};

export default collectModalInfo;
